﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;

namespace WEEK10_LECTURE_DEMO
{
    public partial class XmlWriterExample01 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            string filePath = "r:\\test.xml";

            XmlWriter writer = XmlWriter.Create(filePath);

            writer.WriteStartDocument();
            writer.WriteStartElement("学生信息");
            writer.WriteStartElement("学生");
            writer.WriteAttributeString("性别", "男");
            writer.WriteElementString("姓名", txtName.Text);
            writer.WriteElementString("年龄", txtAge.Text);

            writer.WriteEndDocument();

            writer.Close();
        }

        protected void txtName_TextChanged(object sender, EventArgs e)
        {
        }
    }
}